package org.demo.handler.cell;

import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.Head;
import com.alibaba.excel.write.handler.AbstractCellWriteHandler;
import com.alibaba.excel.write.handler.CellWriteHandler;
import com.alibaba.excel.write.handler.WriteHandler;
import com.alibaba.excel.write.merge.AbstractMergeStrategy;
import com.alibaba.excel.write.metadata.holder.WriteSheetHolder;
import com.alibaba.excel.write.metadata.holder.WriteTableHolder;
import com.alibaba.excel.write.style.AbstractCellStyleStrategy;
import com.alibaba.excel.write.style.AbstractVerticalCellStyleStrategy;
import com.alibaba.excel.write.style.column.AbstractColumnWidthStyleStrategy;
import com.alibaba.excel.write.style.column.AbstractHeadColumnWidthStyleStrategy;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;

import java.util.List;

/**
 * 单元格写处理器
 *
 * @author yexi
 * @see WriteHandler 写处理器，所有写处理器的父接口
 */
public class CustomCellWriteHandler implements CellWriteHandler {

    /**
     * 在创建单元格之前被调用
     */
    @Override
    public void beforeCellCreate(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder, Row row, Head head, Integer columnIndex, Integer relativeRowIndex, Boolean isHead) {

    }

    /**
     * 在创建单元格之后被调用
     */
    @Override
    public void afterCellCreate(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder, Cell cell, Head head, Integer relativeRowIndex, Boolean isHead) {

    }

    @Override
    public void afterCellDataConverted(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder, CellData cellData, Cell cell, Head head, Integer relativeRowIndex, Boolean isHead) {

    }

    /**
     * 在单元格创建并且设值之后被调用
     */
    @Override
    public void afterCellDispose(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder, List<CellData> cellDataList, Cell cell, Head head, Integer relativeRowIndex, Boolean isHead) {

    }

    /**
     * 接口的扩展子类介绍，统一展列
     *
     * @see CellWriteHandler extends WriteHandler 单元格写处理器
     * @see AbstractCellWriteHandler implements CellWriteHandler 单元格写处理器抽象类，不提供实现，供予继承
     * @see AbstractColumnWidthStyleStrategy extends AbstractCellWriteHandler 单元格宽度策略抽象类，默认重写afterCellDispose要求设置宽度，需要子类自行实现setColumnWidth方法
     * @see AbstractHeadColumnWidthStyleStrategy extends AbstractColumnWidthStyleStrategy 头部标题单元格宽度策略抽象类，默认重写setColumnWidth仅在isHead为true时设置宽度，需要子类实现columnWidth方法来计算head的宽度
     * <p>
     * @see AbstractCellStyleStrategy implements CellWriteHandler 单元格样式策略抽象类，默认重写afterCellDispose要求设置样式，需要子类自行实现setHeadCellStyle和setContentCellStyle方法。约束: 要求必须有表头。
     * @see AbstractVerticalCellStyleStrategy extends AbstractCellStyleStrategy 竖向单元格样式策略抽象类，默认重写setHeadCellStyle和setContentCellStyle方法，需要子类实现headCellStyle和contentCellStyle方法
     * <p>
     * @see AbstractMergeStrategy implements CellWriteHandler 非头部单元格合并策略抽象类，默认重写afterCellDispose要求设置合并(并且如果是Head则不处理)，需要子类自行实现merge方法
     */
    private void expandIntroduce() {

    }


}
